package com.wdd.studentmanager;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.StringUtils;

import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;

@MapperScan("com.wdd.studentmanager.mapper")
@SpringBootApplication()
public class StudentmanagerApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(StudentmanagerApplication.class, args);
        ConfigurableEnvironment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StringUtils.isEmpty(path)) {
            path = "";
        }
        log.print("\n----------------------------------------------------------\n\t" + "Application  is running! Access URLs:\n\t" + "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" + "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" + "----------------------------------------------------------");
    }
}

